package org.xxpay.task.reconciliation.scheduled;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.xxpay.core.common.util.MyLog;
import org.xxpay.core.entity.PayAlizftMchInfo;
import org.xxpay.task.common.service.CommonService;

@Component
public class TodayAmountScheduled {

    private static final MyLog _log = MyLog.getLog(TodayAmountScheduled.class);

    @Autowired
    private CommonService commonService;

    @Scheduled(cron="0 0 0 ? * *")   // 每日00:00执行一次
    @Async
    public void resetAmount() {

        _log.info("开始重置今日数据");
        long startTime = System.currentTimeMillis();
        commonService.mchAccountService.resetTodayAmount();
        commonService.agentAccountService.resetTodayAmount();

        //每日更新为0
        PayAlizftMchInfo updateRecord = new PayAlizftMchInfo();
        updateRecord.setDayAmount(0L);
        commonService.payAlizftMchInfoService.updateByCondition(updateRecord, null, null);
        long endTime = System.currentTimeMillis();
        _log.info("重置今日数据结束,耗时:{} ms", endTime - startTime);
    }


}
